package com.ifood.system.service.impl;


import com.ifood.common.core.domain.entity.FoodOrderMaster;
import com.ifood.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ifood.system.mapper.FoodOrderMasterMapper;
import com.ifood.system.service.IFoodOrderMasterService;

import java.util.List;

/**
 * 订单Service业务层处理
 *
 * @author ifood
 * @date 2024-01-14
 */
@Service
public class FoodOrderMasterServiceImpl implements IFoodOrderMasterService {
    @Autowired
    private FoodOrderMasterMapper foodOrderMasterMapper;

    /**
     * 查询订单
     *
     * @param orderId 订单主键
     * @return 订单
     */
    @Override
    public FoodOrderMaster selectFoodOrderMasterByOrderId(String orderId) {
        return foodOrderMasterMapper.selectFoodOrderMasterByOrderId(orderId);
    }

    /**
     * 查询订单列表
     *
     * @param foodOrderMaster 订单
     * @return 订单
     */
    @Override
    public List<FoodOrderMaster> selectFoodOrderMasterList(FoodOrderMaster foodOrderMaster) {
        return foodOrderMasterMapper.selectFoodOrderMasterList(foodOrderMaster);
    }

    /**
     * 新增订单
     *
     * @param foodOrderMaster 订单
     * @return 结果
     */
    @Override
    public int insertFoodOrderMaster(FoodOrderMaster foodOrderMaster) {
        foodOrderMaster.setCreateTime(DateUtils.getNowDate());
        return foodOrderMasterMapper.insertFoodOrderMaster(foodOrderMaster);
    }

    /**
     * 修改订单
     *
     * @param foodOrderMaster 订单
     * @return 结果
     */
    @Override
    public int updateFoodOrderMaster(FoodOrderMaster foodOrderMaster) {
        foodOrderMaster.setUpdateTime(DateUtils.getNowDate());
        return foodOrderMasterMapper.updateFoodOrderMaster(foodOrderMaster);
    }

    /**
     * 批量删除订单
     *
     * @param orderIds 需要删除的订单主键
     * @return 结果
     */
    @Override
    public int deleteFoodOrderMasterByOrderIds(String[] orderIds) {
        return foodOrderMasterMapper.deleteFoodOrderMasterByOrderIds(orderIds);
    }

    /**
     * 删除订单信息
     *
     * @param orderId 订单主键
     * @return 结果
     */
    @Override
    public int deleteFoodOrderMasterByOrderId(String orderId) {
        return foodOrderMasterMapper.deleteFoodOrderMasterByOrderId(orderId);
    }
}
